package cn.hxzy.mapper;

import cn.hxzy.domain.Course;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
@Repository
public interface CourseMapper extends BaseMapper<Course> {
    //查所有包含directionId的课程
   @Select("SELECT * FROM sys_course WHERE FIND_IN_SET(#{directionId}, direction_id) > 0;")
   List<Course> selectListByDid(int directionId);
   //查所有包含professionalId的课程
    @Select("SELECT * FROM sys_course WHERE professional_id=#{professionalId}")
    List<Course> selectListByPid(int professionalId);
    //专业编号和方向编号
    @Select("SELECT *  \n" +
            "FROM sys_course  \n" +
            "WHERE professional_id = #{professionalId}  \n" +
                "  AND FIND_IN_SET(#{directionId}, direction_id) > 0;")
    List<Course> selectListByPidAndDid(Integer professionalId, Integer directionId);
   //模糊查询
    @Select("select * from sys_course where course_name like CONCAT('%',#{courseName},'%')")
    List<Course> selectListByName(String courseName);
    @Select("SELECT * FROM \n" +
            "sys_course \n" +
            "WHERE FIND_IN_SET(#{directionId}, direction_id) > 0 AND\n" +
            " course_name LIKE CONCAT('%',#{courseName},'%')")
    List<Course> selectListByNameAndDid(String courseName,Integer directionId);
    //类型和课程名字模糊查询
    @Select("SELECT * FROM \n" +
            "sys_course WHERE\n" +
            "professional_id=#{professionalId} AND\n" +
            " course_name LIKE CONCAT('%',#{courseName},'%')")
    List<Course> selectListByNameAndPid(String courseName,Integer professionalId);
    //根据类型编号和方向编号和课程名字模糊查询
    @Select("SELECT * FROM \n" +
            "sys_course WHERE\n" +
            "professional_id=#{professionalId} \n" +
            " AND FIND_IN_SET(#{directionId}, direction_id) > 0 AND\n" +
            " course_name LIKE CONCAT('%',#{courseName},'%')")
    List<Course> selectListByNameAndPidAndDid(String courseName,Integer professionalId,Integer directionId);


    @Select("select * from sys_course where course_name=#{courseName} and deleted=0")
    Course getCourseByName(String courseName);

}
